<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .div1 {
      width: 100px;
      height: 100px;
      background-color: red;
    }
    #div1 {
      position: relative;
      top: 50px;
      left: 50px;
    }
    #div2 {
      position: relative;
      top: -50px;
      left: -50px;
    }
  </style>
</head>
<body>
  <div id="app">
    <p>v-model,用在输入框上，可以控制输入框的值,获取值以及修改值</p>
    <input type="text" v-model="name" placeholder="请输入用户名">
    <p>用户名：{{name}}</p>
    <hr>
    <p>v-bind:绑定标签属性，使属性值变成一个变量;语法糖（缩写）是:</p>
    <div class="div1" v-bind:id="idname"></div>
    <input v-bind:type="type1" :qwer="df">
    <hr>
    <p>v-once单次渲染,以后数据更新，dom不再更新</p>
    <p v-once>{{name}}</p>
    <hr>
    <p>v-on:事件监听，语法糖写法@</p>
    <button @click="sayHi">过生日</button>
  </div>
  <script src="../vue.js"></script>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        name: 'Tom',
        idname: 'div1',
        type1: 'password',
        df: '666',
        age: 18
      },
      methods: {
        sayHi() {
          console.log('Hi ~');
          console.log(this.age);
          // 修改数据
          this.age ++;
          console.log(this.age);
        }
      },
    })
  </script>
</body>
</html>